// 状态列表 1待处理/2待调价/3待审核/4已处理
const STATE_OPTIONS = [
  {
    label: '待处理',
    value: '1'
  },
  {
    label: '调价中',
    value: '2'
  },
  {
    label: '待审核',
    value: '3'
  },
  {
    label: '已处理',
    value: '4'
  },
]

// 调价单类型
const RECORD_COMMIT_TYPE_OPTIONS = [
  {
    label: '修改进价单计量',
    value: 'supplyPrice'
  },
  {
    label: '修改进价多计量',
    value: 'supplySteelPrice'
  },
  {
    label: '修改售价单计量',
    value: 'salePrice'
  },
  {
    label: '修改售价多计量',
    value: 'saleSteelPrice'
  },
  {
    label: '批量修改进价',
    value: 'batchModifySupplyPriceRecord'
  },
]

export const PRICE_STATE_OPTIONS = [
  {
    label: '是',
    value: 1
  },
  {
    label: '否',
    value: 2
  },
]
// 初始化查询条件
export const initFormItemList = (centerDept) => {
  return [
    {
      prop: 'name',
      label: '原材料名称',
      type: 'input'
    },
    {
      prop: 'state',
      label: '处理状态',
      type: 'select',
      options: STATE_OPTIONS
    },
    // floatRadioFrom floatRadioTo
    {
      prop: 'floatRadio',
      label: '浮动率(%)',
      type: 'range',
      rangeType: 'inputNum',
      precision: 2,
      props: ['floatRadioFrom', 'floatRadioTo']
    },
    {
      prop: 'supplyNoOrName',
      label: '供应商',
      type: 'input'
    },
    {
      prop: 'authDepartmentNo',
      label: '归属中心',
      type: 'selectFilter',
      filterable: true,
      clearable: true,
      allOptions: centerDept || [],
      options: [],
    },
    // unAdjustPriceTimesFrom unAdjustPriceTimesTo
    {
      prop: 'unAdjustPriceTimes',
      label: '连续未调价次数',
      type: 'range',
      rangeType: 'inputNum',
      precision: 0,
      props: ['unAdjustPriceTimesFrom', 'unAdjustPriceTimesTo']
    },
    {
      prop: 'createOpeTime',
      label: '触动预警值日期',
      type: 'datePicker',
      datePickerType: 'daterange',
      valueFormat: 'yyyy-MM-dd'
    },
    {
      prop: 'associatedRecordCommitTypes',
      label: '调价单类型',
      type: 'select',
      multiple: true,
      options: RECORD_COMMIT_TYPE_OPTIONS
    },
  ]
}
// 列表表头
export const getTableColumns = (parent) => {
  return [
    {
      title: '单据号',
      key: 'recordNo',
    },
    // 1待处理/2待调价/3待审核/4已处理
    {
      title: '处理状态',
      key: 'stateStr',
    },
    {
      title: '原材料编码',
      key: 'rawMaterialId',
    },
    {
      title: '原材料名称',
      key: 'rawMaterialName',
    },
    {
      title: '原材料规格',
      key: 'rawMaterialSpec'
    },
    {
      title: '原材料生产商',
      key: 'rawMaterialProducer'
    },
    {
      title: '预警起始价格',
      key: 'rawMaterialWarningPrice',
    },
    {
      title: '预警起始价格日期',
      key: 'rawMaterialWarningPriceStartTime'
    },
    {
      title: '触动预警值当日价格',
      key: 'rawMaterialPrice'
    },
    {
      title: '触动预警值日期',
      key: 'createOpeTime'
    },
    {
      title: '今日距起始浮动率',
      key: 'floatRadioStr'
    },
    {
      title: '浮动金额',
      key: 'floatPrice',
    },
    {
      title: '供应商代码',
      key: 'supplyUuid',
    },
    {
      title: '供应商名称',
      key: 'supplyName',
    },
    {
      title: '是否金属',
      key: 'supplyMetalStr',
    },
    {
      title: '合作品牌',
      key: 'supplyBrand',
    },
    {
      title: '供应商级别',
      key: 'supplyLevelStr',
    },
    {
      title: '供应商管理区域',
      key: 'supplyManagementAreaName'
    },
    {
      title: '业务联系人',
      key: 'supplyContactPerson'
    },
    {
      title: '业务区域',
      key: 'businessAreaName'
    },
    {
      title: '归属部门',
      key: 'authDepartmentName'
    },
    {
      title: '业务对接人',
      key: 'supplyBusinessContactPerson'
    },
    {
      title: '供应商类别',
      key: 'supplyTypeStr'
    },
    {
      title: '去年进货额',
      key: 'supplyLastYearAmount'
    },
    {
      title: '本年进货额',
      key: 'supplyYearAmount'
    },
    {
      title: '价格管理周期',
      key: 'supplyPriceControlCycle'
    },
    {
      title: '是否需调整售价/进价',
      key: 'adjustPriceStateStr',
      render: (h, { row }) => {
        return <span>{row.state == 1 ? '' : row.adjustPriceStateStr}</span>
      }
    },
    {
      title: '处理备注说明',
      key: 'processRemark',
      render: (h, { row }) => {
        return <span>{row.state == 1 ? '' : row.processRemark}</span>
      }
    },
    {
      title: '处理人',
      key: 'processName',
      render: (h, { row }) => {
        return <span>{row.state == 1 ? '' : row.processName}</span>
      }
    },
    {
      title: '处理时间',
      key: 'processTime',
      render: (h, { row }) => {
        return <span>{row.state == 1 ? '' : row.processTime}</span>
      }
    },
    {
      title: '审核人',
      key: 'approveName',
      render: (h, { row }) => {
        // 非已处理的不显示审核人
        return <span>{row.state < 4 ? '' : row.approveName}</span>
      }
    },
    {
      title: '审核时间',
      key: 'approveTime',
      render: (h, { row }) => {
        // 非已处理的不显示审核时间
        return <span>{row.state < 4 ? '' : row.approveTime}</span>
      }
    },
    {
      title: '连续预警未调价次数',
      key: 'unAdjustPriceTimes',
      width: 130
    },
    {
      title: '调价单据号',
      key: 'associatedRecordNo',
      width: 120,
      render: (h, { row }) => {
        return <a onClick={ () => { parent.viewRecordDetail(row) }}>{row.associatedRecordNo}</a>
      }
    },
    {
      title: '调价单类型',
      key: 'associatedRecordCommitTypeStr',
      width: 130
    },
  ]
}
